/*
 *  Copyright (c) 2022 ZhuHai Jieli Technology Co.,Ltd.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#include "boot.h"
#include "debug.h"
#include "typedef.h"

void mkey_dummy_func(void)
{
}

BOOT_INFO boot_info SEC(.boot_info);

void printf_boot_info(void)
{
    put_buf((void *) &boot_info, sizeof(boot_info));
}

SEC_USED(.boot_code)
void boot_info_init(void *_info)
{

#if (USE_SDFILE_NEW == 1)
    BOOT_DEVICE_INFO *info = (BOOT_DEVICE_INFO *)_info;
    memcpy_s(&(boot_info.sfc), sizeof(struct sfc_info), &(info->sfc), sizeof(struct sfc_info));
    boot_info.flash_size = info->fs_info->FlashSize;
    boot_info.vm.align = info->fs_info->align;
    boot_info.chip_id = info->chip_id;
    boot_info.trim_value = info->trim_value;
    memcpy_s(&(boot_info.mac), sizeof(boot_info.mac), info->bt_mac_addr, sizeof(boot_info.mac));
#else
    BOOT_INFO *info = (BOOT_INFO *)_info;
    memcpy_s(&boot_info, sizeof(BOOT_INFO), info, sizeof(BOOT_INFO));
#endif

    mkey_dummy_func();
}

u32 boot_info_get_sfc_base_addr(void)
{
    return boot_info.sfc.sfc_base_addr;
}

